//
//  ExpressCell.m
//  CYWFrame
//
//  Created by Macx on 2017/9/17.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "ExpressCell.h"

#import "ExpressTraces.h"

@implementation ExpressCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    CGSize size = [LZCTools textSizeWithText:@"x" font:kUHSystemFontWithSize(12)];
    
    self.icon.frame = CGRectMake(10, 0, size.height+10, size.height+10);
    
    self.state.font = kUHSystemFontWithSize(12);
    self.state.numberOfLines = 0;
    
    self.time.font = kUHSystemFontWithSize(12);
    
}

- (void)setModel:(ExpressTraces *)model {
    
    if (_model != model) {
        _model = model;
        
//        static int new = 0;
        
        self.state.text = model.AcceptStation;
        
        CGSize size = [LZCTools textSizeWithText:@"x" font:kUHSystemFontWithSize(12)];
        CGFloat stateW = SCREEN_WIDTH-size.height-40;
        CGSize size2 = [self.state.text sizeWithFont:kUHSystemFontWithSize(12) constrainedToSize:CGSizeMake(stateW, size.height*1000) lineBreakMode:NSLineBreakByWordWrapping];
        
        self.state.frame = CGRectMake(self.icon.x+self.icon.width+10, 10, stateW, size2.height);
        
        self.time.text = model.AcceptTime;
        self.time.frame = CGRectMake(self.state.x, self.state.y+self.state.height+10, self.state.width, size.height);
        
        self.icon.centerY = self.state.centerY;
        
        if (self.row == 0) {
            [self.icon setImage:[IMAGE(@"logistics_grren") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
            self.state.textColor = kBlackColor;
        }
        else {
            [self.icon setImage:[IMAGE(@"logistics_grey") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
            self.state.textColor = kLightGrayColor;
        }
    
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
